package database.alarm;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


public class DBHelper extends SQLiteOpenHelper{
	
	public static final String TAG ="DBAdapter";
	
	public static final String KEY_ID = "id";
	public static final String KEY_TIME = "time";
	public static final String KEY_DAY = "day";/*thu*/
	public static final String KEY_DATE = "date";/*ngay*/
	public static final String KEY_TYPE = "type";/*1: alarm hang ngay, 0:alarm 1 lan*/
	public static final String KEY_STATUS = "status";/*1: enable, 0:disable*/
	public static final String KEY_WORK = "work";
	public static final String KEY_AUDIOALARM = "audio"; 			
	
	private static final String DATABASE_NAME = "DB_Alarm";
	public static final String DATABASE_TABLE = "TBL_Alarm";
	private static final String CREATE_TBL = "create table "+DATABASE_TABLE+" ("+KEY_ID+" integer primary key autoincrement," +
																KEY_TIME + " text not null, "+KEY_DAY+ " text not null, "+KEY_DATE+" text, "+
																KEY_TYPE +" integer not null, " +KEY_STATUS+" integer not null, "+
																KEY_WORK +" text, "+KEY_AUDIOALARM+" text not null);";
	private static final String DROP_TBL = "DROP TABLE IF EXISTS "+DATABASE_TABLE; 
	private static final int DATABASE_VERSION = 1;	
	
	public DBHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_TBL);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.i(TAG, "Upgrading DB");
		db.execSQL(DROP_TBL);
		onCreate(db);
		
	}

}
